﻿@{
    ViewBag.Title = "ClearTest";
    Layout = "~/Views/Shared/_LayoutForClear.cshtml";
}

<div class="easyui-panel" data-options="fit:true,title:'test'">
    <table id="dg" class="easyui-datagrid" data-options="toolbar:'#t',idField:'code'">
        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:true"></th>
                <th data-options="field:'code'">Code</th>
                <th data-options="field:'name'">Name</th>
                <th data-options="field:'price'">Price</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td><td>001</td>
                <td>name1</td>
                <td>2323</td>
            </tr>
            <tr>
                <td></td><td>002</td>
                <td>name2</td>
                <td>4612</td>
            </tr>
            <tr>
                <td></td><td>003</td>
                <td>name2</td>
                <td>4612</td>
            </tr>
            <tr>
                <td></td><td>004</td>
                <td>name2</td>
                <td>4612</td>
            </tr>
        </tbody>
    </table>
    <div id="t">
        <a id="del" class="easyui-linkbutton">测试删除</a>
    </div>
</div>

<script>
    $(function () {
        $("#del").click(function () {
            var checked = $.array.clone($("#dg").datagrid("getChecked"));

            $.each(checked, function (i, row) {
                var index = $("#dg").datagrid("getRowIndex", row);
                if (index > -1) { $("#dg").datagrid("deleteRow", index); }
                
            });
            $("#dg").datagrid("clearSelections");
        });
    });
</script>

